import request from '@/utils/request';
import type { BaseBeanModel, ResponsePageData, ResponseBaseData, QueryParamModel } from '@/api/model/baseModel';
import type { downloadParam } from '@/utils/download-util';
import { downloadSysFile } from '@/utils/download-util';
const basePath = '/bpm/bpmpi/bpmpiprocesss';
/** 过程类型目录与流程关系表 */
export interface BpmPiProcessDto extends BaseBeanModel {
  /** 流程定义ID */
  dbid?: string;
  /** 过程分类ID */
  categoryId?: string;
  /** 流程文件KEY */
  bpmProcessKey?: string;
  /** 所属应用系统ID */
  sysApplicationId?: string;
}

/** 获取分页数据 */
export function listBpmPiProcessByPage(param: QueryParamModel): Promise<ResponsePageData<BpmPiProcessDto>> {
  return request.post(`${basePath}/find-list-by-page/v1`, param);
}

/** 根据id加载数据 */
export function getBpmPiProcess(id: string): Promise<ResponseBaseData<BpmPiProcessDto>> {
  return request.get(`${basePath}/get/${id}/v1`);
}

/** 保存表单数据 */
export function saveBpmPiProcess(form: BpmPiProcessDto): Promise<ResponseBaseData<any>> {
  return request.post(`${basePath}/save/v1`, form);
}

/** 根据id集合删除数据 */
export function delBpmPiProcess(ids: [string]): Promise<ResponseBaseData<any>> {
  return request.delete(`${basePath}/delete-by-ids/v1`, { data: ids });
}
/**
 * 根据过程实例id获取子流程列表
 * @param param
 * @returns
 */
export function getSubFlowListBybpmPiInstanceId(param: any): Promise<ResponseBaseData<any>> {
  return request.post(`/bpm/bpmengine/reform/getSubProcessList/v1`, param);
}
/** 导出Excel */
export function exportExcel(param: any) {
  const download = {
    url: `${basePath}/export-data/v1`,
    data: param,
    method: 'post'
  } as downloadParam;
  return downloadSysFile(download);
}
